package com.Test;

import java.util.ArrayList;

public class Test06 {
    public static void main(String[] args) {

        Product product = new Product(15, 20);

        int count = 6;

        int chushizhi = 0;

        int days = product.getDays() / count;
        int machines = product.getMachines() / count;

        ArrayList<Product> list = new ArrayList<>();

        for (int i = 0; i < count; i++) {

            Product product1 = new Product();

            chushizhi++;

            // 如果是最后一条数据
            if (chushizhi == count - 1) {
                if ((count - 1) * days == product.getDays()) {
                    continue;
                } else {
                    product1.setDays(product.getDays() - (count - 1) * days);
                    product1.setMachines(product.getMachines() - (count - 1) * machines);
                }
                if ((count - 1) * machines == product.getMachines()) {
                    continue;
                } else {
                    product1.setDays(product.getDays() - (count - 1) * days);
                    product1.setMachines(product.getMachines() - (count - 1) * machines);
                }
            } else {
                product1.setDays(days);
                product1.setMachines(machines);
            }

            list.add(product1);
        }

        for (Product product1 : list) {
            System.out.println(product1);
        }
    }
}